package cn.tedu.spring.example;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.applet.AppletContext;

/**
 * @Author Justin Parker
 * @Date 2024/8/2 0002 10:17
 * @Version 1.0
 */
public class TextUser {
    public static void main(String[] args) {
        /**
         *  1.让Spring Framwork创建java对象,并放入IOC容器中；
         *  2.从IOC容器中获取java对象；
         *  3.调用java对象的方法；
         */
        ApplicationContext context = new AnnotationConfigApplicationContext("cn.tedu.spring.example ");

        User user = context.getBean(User.class);

        user.run();

        /**
         * 第二种方式，xml文件配置bean
         */
//        ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");
//
//        User user = context.getBean(User.class);
//        user.run();
    }
}
